#pragma once
#include "SPK.h"
#include <string>
#include <iostream>
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Geometry>
#include <osg/Drawable>
#include <osg/Geode>
#include <osg/Point>
#include <osgEarth/GLUtils>
#include <osg/LineWidth>
using std::cout;
using std::endl;

struct WRainRender:public SPK::Renderer {
	SPK_IMPLEMENT_REGISTERABLE(WRainRender);
	virtual void render(const SPK::Group& group);
	virtual void setBlending(SPK::BlendingMode blendMode);
};




struct WSparkRain
{
	WSparkRain(int maxNumOfParticle);
	~WSparkRain();

	void update(float seconds);
	void render();
	
	osg::Geode* getNode() { return _node.get(); }
	

	SPK::Model* _model;
	SPK::Ring* _zone;
	SPK::NormalEmitter* _emitter;
	SPK::System* _system;
	SPK::Group* _group;

	osg::ref_ptr<osg::Geode> _node;
	int getNumOfParticles() { return _numOfPartiles; }

private:
	void updateTheGeometry();

	osg::ref_ptr<osg::Geometry> _geometry;
	int _numOfPartiles;
};


struct WSparkRainNodeCallback : public osg::NodeCallback {
	WSparkRainNodeCallback(WSparkRain* wrain) :_wrain(wrain) {}
	virtual void operator() (osg::Node* node, osg::NodeVisitor* nv);

	WSparkRain* _wrain;
};
